<?php

/**
 * @author Martin Pernica
 * @copyright 2009
 */

Text::h1( Lang::getBack('com_sections', 'admin') );

if(empty($_GET['a'])){
echo '<table cellspacing="15" cellpadding="15">';
echo '<tr><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'] .'&a=new"><img src="../libs/icons/add.png" /> '.Lang::getBack('com_sections', 'add').'</a></td></tr>';
echo '</table><br />';


$query = Registry::get('db')->query("SELECT * FROM {prefix}sections ORDER BY id DESC");

echo '<table cellspacing="20" cellpadding="30">';
echo '<tr><th>'.Lang::getBack('com_sections', 'name').'</th><th>'.Lang::getBack('com_sections', 'description').'</th><th>'.Lang::getBackGlobal('action').'</th></tr>';
while($data = $query->fetch_array()){
	echo '<tr><td>'.$data['name'].'</td><td>'.$data['description'].'</td><td><a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&a=delete&id='.$data['id'].'"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="'.$_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'].'&a=edit&id='.$data['id'].'"><img src="../libs/icons/style_edit.png" /></a></td></tr>';
}
echo '</table>';

}else {
	switch($_GET['a']){
		case 'new':
		require 'new.php';
		break;

		case 'delete':
		require 'delete.php';
		break;

		case 'edit':
		require 'edit.php';
		break;
	}
}


?>